home *** CD-ROM | disk | FTP | other *** search
- Path: phcoms4.seri.philips.nl!news
- From: Harry Franken <H.Franken@nl.cis.philips.com>
- Newsgroups: comp.lang.c
- Subject: Re: Date question
- Date: Thu, 29 Feb 1996 11:26:46 -0800
- Organization: Philips Medical Systems Netherlands
- Message-ID: <3135FDF6.3802@nl.cis.philips.com>
- References: <4h3kpb$i3s@news.ysu.edu>
- NNTP-Posting-Host: dialin-01.ehv.cp.philips.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I; 16bit)
-
- Jerry Tomko wrote:
- >
- >
- > Hello. Does anyone know where I can find a program that,
- > when given the month, day, and year, will determine the
- > corrosponding day of the week (Sunday, Monday, Tuesday, etc..)?
- >
- > Jerry.
- >
- >
- > --
-
-
- Hai jerry,
-
- Using program below should do it.
-
- Harry.
- +-------------------------------------- start -------------+
- year = ?
- month = ?
- day = ?
-
- if (month <= 2 )
- {
- year = year - 1;
- month = month + 12;
- }
-
- previous_century = year / 100;
- year = year - (previous_century * 100);
- result = (((26001L) * (month - 2L) - 2000L) / 10000L)
- + day + year + (year / 4) +
- (previous_century / 4) - (2 * previous_century);
-
- day_in_week = (result - (result / 7L) * 7L) ;
- +--------------------------------------- end ----------------------+
-